package com.company.app.serviceImpl;

import java.util.Arrays;
import java.util.List;

import javax.jws.WebService;
import javax.xml.ws.WebServiceException;

import com.company.app.bo.ProductTypeBO;
import com.company.app.entities.ProductType;
import com.company.app.service.ProductTypeService;

/**
 * The Class ProductTypeServiceImpl.
 */
@WebService(endpointInterface="com.company.app.service.ProductTypeService", name="ProductTypeService")
public class ProductTypeServiceImpl implements ProductTypeService {
	
	/** The product type bo. */
	private ProductTypeBO productTypeBO;

	/**
	 * Sets the product type bo.
	 *
	 * @param productTypeBO the new product type bo
	 */
	public void setProductTypeBO(ProductTypeBO productTypeBO) throws WebServiceException {
		this.productTypeBO = productTypeBO;
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#getAllProductTypes()
	 */
	@Override
	public List<ProductType> getAllProductTypes() {
		return this.productTypeBO.getAllProductType();
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#searchProductTypeByFilter(com.company.app.entities.ProductType)
	 */
	@Override
	public List<ProductType> searchProductTypeByFilter(
			ProductType producTypeFilter) throws WebServiceException {
		return this.productTypeBO.searchProductTypes(Arrays.asList(producTypeFilter));
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#getProductTypeById(java.lang.Long)
	 */
	@Override
	public ProductType getProductTypeById(Long id) throws WebServiceException {
		return this.productTypeBO.getProductById(id);
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#createProductType(com.company.app.entities.ProductType)
	 */
	@Override
	public boolean createProductType(ProductType productType) throws WebServiceException {
		return this.productTypeBO.createProductType(productType)!=null;
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#updateProductType(com.company.app.entities.ProductType)
	 */
	@Override
	public boolean updateProductType(ProductType productType) throws WebServiceException {
		return this.productTypeBO.updateProductType(productType);
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#deleteProduct(com.company.app.entities.ProductType)
	 */
	@Override
	public boolean deleteProduct(ProductType productType) throws WebServiceException {
		return this.productTypeBO.deleteProductType(productType);
	}

	/* (non-Javadoc)
	 * @see com.company.app.service.ProductTypeService#createTmpProduct()
	 */
	@Override
	public ProductType createTmpProduct() throws WebServiceException {
		ProductType newProductType = new ProductType();
		newProductType.setName("N/A");
		return this.productTypeBO.createProductType(newProductType);
	}
	

}
